package demo;

import java.util.function.DoubleToIntFunction;

public class Test2 {
    public static void main(String[] args) {
        Animal animal = new Dog(1 ,"小狗");
        animal.eat();
    }
    public static void main1(String[] args) {
        Animal animal = new Dog(1 , "小狗") ;
        animal.color = "红色" ;
        System.out.println(animal);
          func1(new Dog(1, "小狗"));

    }
    public static void func1(Animal animal){
        animal.eat();
    }

    public static Animal func2() {
        return new Dog(1 , "小狗") ;
    }
}
class Animal{
    String name ;
    int age ;
    String color ;
    public Animal eat (){
        System.out.println(this.name + "正在吃饭");
        return null ;
    }
   Animal(int age , String name){
        this.name = name ;
        this.age = age ;

   }
    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", color='" + color + '\'' +
                '}';
    }

}
class Cat extends Animal{
    Cat(int age ,String name ){
        super(age,name);
    }
    public void miMi(){
        System.out.println(this.name + "正在咪咪叫");
    }

}
class Dog extends Animal{
    Dog (int age ,String name ){
        super(age,name);
    }
    @Override
    public Cat eat(){
        System.out.println(this.name + "正在吃狗粮");
        return null ;
    }
    public void wangWang(){
        System.out.println(this.name + "正在旺旺叫");
    }
}
